import os

import cv2

'''删除所有帧数小于16帧的clip'''
# 获取数据集视频的类别数，并根据类名创建相应的文件夹
# src_dir = r'D:\pycharmProj\pytorch-video-recognition\data\UAV2'
# src_dir = r'E:\uav_datasets\Drone_detection_dataset-UAV2-3dCNN'
src_dir = r'E:\uav_datasets\Drone-Detection-RTB-UAV4'
cls_name = {'AIRPLANE',
            'BIRD',
            'DRONE',
            'HELICOPTER'}
# 获取分类名，组成集合
print(cls_name)
vid_cnt = 0
cnt = 0
# 创建每个分类的目录
for cls_nm in cls_name:
    cls_path = os.path.join(src_dir, cls_nm)
    for vid in os.listdir(cls_path):
        vid_path = os.path.join(cls_path, vid)
        camera = cv2.VideoCapture(vid_path)  # 参数0表示第一个摄像头
        frames = int(camera.get(7))
        # print('frames', frames)
        vid_cnt += 1
        if frames != 16:
            cnt += 1
            print('frames', frames)
            print('===================================', vid_path)
            camera.release()
            # os.remove(vid_path)
        else:
            camera.release()

print('cnt', cnt)
print('vid_vnt', vid_cnt)
